package com.example.service.impl;

import com.example.common.PageResult;
import com.example.dto.RepairPageDto;
import com.example.entity.Repair;
import com.example.mapper.RepairMapper;
import com.example.service.RepairService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RepairServiceImpl implements RepairService {
    @Autowired
    private RepairMapper repairMapper;
    @Override
    public PageResult page(RepairPageDto repairPageDto) {
        PageHelper.startPage(repairPageDto.getPageNum(),repairPageDto.getPageSize());
         Page<Repair> page =  repairMapper.getByDnoWithPno(repairPageDto);
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void add(Repair repair) {
        repairMapper.add(repair);
    }

    @Override
    public void deleteByDno(String dno,String pno) {
        repairMapper.deleteByDno(dno,pno);
    }

    @Override
    public void update(Repair repair) {
        repairMapper.update(repair);
    }
}
